package io.renren.modules.admin.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.admin.entity.AboutUsEntity;
import io.renren.modules.admin.service.AboutUsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 加盟机构（加入我们）
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-12-17 18:24:00
 */
@RestController
@RequestMapping("admin/aboutus")
public class AboutUsController {
    @Autowired
    private AboutUsService aboutUsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("admin:aboutus:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = aboutUsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{aboutUsId}")
    @RequiresPermissions("admin:aboutus:info")
    public R info(@PathVariable("aboutUsId") Long aboutUsId){
		AboutUsEntity aboutUs = aboutUsService.getById(aboutUsId);

        return R.ok().put("aboutUs", aboutUs);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("admin:aboutus:save")
    public R save(@RequestBody(required = true) AboutUsEntity aboutUs){
		aboutUsService.save(aboutUs);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("admin:aboutus:update")
    public R update(@RequestBody AboutUsEntity aboutUs){
		aboutUsService.updateById(aboutUs);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("admin:aboutus:delete")
    public R delete(@RequestBody Long[] aboutUsIds){
		aboutUsService.removeByIds(Arrays.asList(aboutUsIds));

        return R.ok();
    }

}
